home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Exchange
/
CD Exchange - Volume 1.iso
/
d.t.p
/
utils
/
others
/
pcal
/
pcal.c
< prev
next >
Wrap
Text File
|
1992-02-21
|
46KB
|
1,561 lines
static char VERSION_STRING[] = "@(#)pcal v4.3 - generate Postscript calendars";
/*
* pcal.c - generate PostScript file to print calendar for any month and year
*
* The original PostScript code to generate the calendars was written by
* Patrick Wood (Copyright (c) 1987 by Patrick Wood of Pipeline Associates,
* Inc.), and authorized for modification and redistribution. The calendar
* file inclusion code was originally written in "bs(1)" by Bill Vogel of
* AT&T. Patrick's original PostScript was modified and enhanced several
* times by King Ables, Tom Tessin, and others whose names have regrettably
* been lost. This C version was originally created by Ken Keirnan of Pacific
* Bell; additional enhancements by Joseph P. Larson, Ed Hand, Andrew Rogers,
* Mark Kantrowitz, Joe Brownlee, Andy Fyfe, and Geoff Kuenning. The moon
* routines were originally written by Jef Poskanzer and Craig Leres, and
* were incorporated into Pcal by Richard Dyson.
*
* Contents:
*
* alt_fopen
* check_numargs
* color_msg
* gen_shading
* get_args
* get_flag
* init_misc
* main
* set_color
* set_debug_flag
* usage
*
* Revision history:
*
* 4.3 AWR 12/06/91 Attempted to simplify some of the
* mysteries surrounding command-line
* parsing; moved some processing from
* get_args() to new check_numargs()
*
* 12/05/91 Search for moon file in directory
* where Pcal lives (cf. moonphas.c)
*
* 12/03/91 Add -s flag to override default values
* for date/fill box shading
*
* 11/22/91 Use cvt_escape() (new; cf. pcalutil.c)
* to convert escape sequences in command
* line strings
*
* 11/18/91 Improve documentation; add init_misc()
* as catch-all for various initializations
*
* 10/25/91 Support moon phases as wildcards
*
* 10/17/91 Add -Z flag to generate debugging
* information; add a pre-pass through
* command line flags to detect -ZO
* prior to parsing PCAL_OPTS
*
* 10/15/91 Revise logic of date file search
*
* 4.2 AWR 10/08/91 Add -k and -K flags to control
* positioning of small calendars
*
* 10/03/91 Add "note{/<n>}" to select box for
* note text (as per Geoff Kuenning)
*
* Add -S flag to suppress generation
* of the small calendars
*
* 10/02/91 Add -N flag to specify alternate
* heading for notes box
*
* Allow user to specify alternate notes
* font size (-n <name>/<size>)
*
* 10/01/91 Add -u flag to generate version info
* and parameter usage message
*
* 09/30/91 Support "if" and "elif" in date file
*
* 09/19/91 Add -c flag to generate input file for
* Un*x "calendar" utility
*
* 4.11 AWR 08/20/91 Add support for "nearest" keyword
* (as per Andy Fyfe)
*
* define "whole_year" when -w set
*
* AWR 08/21/91 Support %u, %w, %D, %M format specs
* and optional number following %[+-]
* (cf. writefil.c)
*
* 4.1 AWR 08/16/91 Add -G flag to print "gray" dates as
* outlined, gray-filled characters
*
* Fix potential bug in julday() (cf.
* moonphas.c)
*
* 4.02 AWR 07/02/91 Add -v flag to print version info only;
* call find_executable() to get true
* program pathname (cf. pcalutil.c);
* add format specifiers to text strings
* (cf. writefil.c)
*
* 4.01 AWR 03/19/91 Incorporate revised moonphas.c (q.v.)
*
* 4.0 AWR 02/24/91 Add alt_fopen() to search for file
* in alternate path; use to look for
* date file in same directory as
* Pcal executable (as per Floyd Miller)
*
* Support negative ordinals (cf.
* readfile.c, pcalutil.c)
*
* Support expressions in preprocessor
* "if{n}def" lines (cf. exprpars.c)
*
* Support "even", "odd" ordinals (cf.
* readfile.c) and ordinals > 5th
*
* Support -B (leave unused boxes blank)
* flag
*
* Separated into moonphas.c, pcal.c,
* pcalutil.c, readfile.c, and writefil.c;
* added support for moon phase file
*
* Support -w (whole year) flag; fix
* various bugs and nonportable constructs
*
* 3.0 AWR 12/10/90 Support concept of "weekday", "workday",
* and "holiday" (and converses)
*
* Substantial revision of program logic:
* extracted pcaldefs.h and pcallang.h,
* moving all language dependencies (even
* flag names) to the latter.
*
* add -I flag to reinitialize all
* flags to program defaults; -j and -J
* flags (print Julian dates); add -x,
* -y, -X, -Y flags (as per Ed Hand)
* for output scaling and translation
*
* allow "wildcard" dates (e.g., "all
* Thursday{s} in Oct", "last Friday in
* all") and notes ("note all <text>);
* print full "help" message (including
* date file syntax)
*
* 2.6 AWR 10/15/90 parse floating dates (e.g. "first
* Monday in September") and relative
* floating dates (e.g., "Friday after
* fourth Thursday in November"); simplify
* logic of -F option; add -F to usage
* message; replace COLOR_MSG() string
* with color_msg() routine; add -h
* (help message) and -A | -E (American |
* European date format) flags; renamed
* flag sets for clarity; more comments
*
* 2.5 JAB 10/04/90 added -F option
*
* 2.4 --- 10/01/90 * no modifications *
*
* 2.3 JWZ/AWR 09/18/90 added moon routines
*
* 2.2 AWR 09/17/90 revise logic of parse(); new usage
* message
*
* JAB/AWR 09/14/90 support "note" lines in date file
*
* 2.1 MK/AWR 08/27/90 support -L, -C, -R, -n options;
* print holiday text next to date
*
* AWR 08/24/90 incorporate cpp-like functionality;
* add -D and -U options; save date file
* information in internal data structure;
* look for PCAL_OPTS and PCAL_DIR; look
* for ~/.calendar and ~/calendar
*
* 2.0 AWR 08/08/90 included revision history; replaced -r
* flag with -l and -p; replaced -s and -S
* flags with -b and -g; recognize flags
* set in date file; translate ( and ) in
* text to octal escape sequence; usage()
* message condensed to fit 24x80 screen
*
* Parameters:
*
* pcal [opts] generate calendar for current month/year
* (current year if -w flag specified)
*
* pcal [opts] yy generate calendar for entire year yy
*
* pcal [opts] mm yy generate calendar for month mm
* (Jan = 1), year yy (19yy if yy < 100)
* (12 months starting with mm/yy if -w
* specified)
*
* pcal [opts] mm yy n as above, for n consecutive months (n
* rounded to next multiple of 12 if -w
* specified)
*
* Output:
*
* PostScript file to print calendars for all selected months.
*
* Options:
*
* -I initialize all parameters to program defaults
*
* -b <DAY> print specified weekday in black
* -g <DAY> print specified weekday in gray
* (default: print Saturdays and Sundays in gray)
*
* -G print "gray" dates as filled outlines
* -O print "gray" dates as unfilled outlines
* (default: gray characters)
*
* -s {<DATE>}{/<FILL>}
* specify alternate shading values for dates
* and fill boxes
* (default: dates = 0.8, fill boxes = 0.9)
*
* -d <FONT> specify alternate font for day names
* (default: Times-Bold)
*
* -n <FONT>{/<SIZE>}
* specify alternate font/size for notes in boxes
* (default: Helvetica-Narrow/6)
*
* -t <FONT> specify alternate font for titles
* (default: Times-Bold)
*
* -D <SYM> define preprocessor symbol
* -U <SYM> un-define preprocessor symbol
*
* -e generate empty calendar (ignore date file)
*
* -f <FILE> specify alternate date file (default:
* ~/.calendar on Un*x, SYS$LOGIN:CALENDAR.DAT
* on VMS, s:calendar.dat on Amiga; if
* environment variable [logical name on VMS]
* PCAL_DIR exists, looks there instead; if
* not found in either place, looks in same
* directory as Pcal executable)
*
* -o <FILE> specify alternate output file (default:
* stdout on Un*x, CALENDAR.PS on VMS,
* RAM:calendar.ps on Amiga)
*
* -L <STRING> specify left foot string (default: "")
* -C <STRING> specify center foot string (default: "")
* -R <STRING> specify right foot string (default: "